$(document).ready(function(){

	//Superbox online
	$.superbox.settings = {
    overlayOpacity: .9, // Background opaqueness
    loadTxt: "Loading...", // Loading text
    closeTxt: "Cerrar", // "Close" button text
    closeOnClick: false,
    closeEsc: false
  };
 	$.superbox();


	//Agregar marcador
	$('#add_marcker_film').one('click', function(){
		var tok = util.getCookie('p_usr_token');
		if(tok != '' && tok != null){
			$(this).addClass('add_marcker');
			$.getJSON(base_url+"services/marker/add",
			{
				oauth_token: tok,
				url: 	$(this).attr('data-url'),
				title: 	$(this).attr('data-title'),
				obj: 	$(this).attr('data-obj'),
				type:	'0'
			},
			function(data){
				msg_actions.show_msg(data.status.message);
			});
		}
	});
	$('#add_marcker_epis').one('click', function(){
		var tok = util.getCookie('p_usr_token');
		if(tok != '' && tok != null){
			$(this).addClass('add_marcker');
			$.getJSON(base_url+"services/marker/add",
			{
				oauth_token: tok,
				url: 	$(this).attr('data-url'),
				title: 	$(this).attr('data-title'),
				obj: 	$(this).attr('data-obj'),
				type:	'1'
			},
			function(data){
				msg_actions.show_msg(data.status.message);
			});
		}else
			msg_actions.show_msg('Debes estar logueado para usar esta función.');
	});
	
	//Asig tooltip
	$('.tipinfo').tipsy({
		opacity: 1,
		html: true,
		live: true,
		gravity: $.fn.tipsy.autoNS,
		fade: true
	});
	
	//Asigna eventos para cambiar de pestaña
	$("#view_online, #view_download, #view_trailer").click(function(){
		$(".post-extra nav ul li").removeClass('sel-extra corner-all8');
		$(this).addClass('sel-extra corner-all8');
		
		$("#sdownload, #sonline, #strailer").css('display', 'none');
		if(this.id == "view_download"){
			$("#sdownload").css('display', 'table');
		}else if(this.id == "view_online"){
			$("#sonline").css('display', 'table');
		}else{
			$("#strailer").css('display', 'table');
		}
	});
	
	//Eventos para calificar la fuente
	$("#reproductor span.good, #reproductor span.bad").click(function(){
		var tok = util.getCookie('p_usr_token');
		if(tok != '' && tok != null){
			$.getJSON(base_url+"services/source/add",
			{
				oauth_token: tok,
				obj: 	$(this).attr('data-obj'),
				opc:	$(this).attr('data-opc'),
				type:	$(this).attr('data-type')
			},
			function(data){
				msg_actions.show_msg(data.status.message);
			});
		}else
			msg_actions.show_msg('Debes estar logueado para usar esta función.');
	});
});
